<?php
/**
 * Created by PhpStorm.
 * UsersF: Mloong
 * Date: 2019/3/2
 * Time: 10:29
 */

namespace app\sign\validate;



use app\sign\model\Account;
use app\sign\model\Sign;
use Driver\Cache\Redis;
use think\Validate;

class loginValidate extends Validate
{
    protected $rule = [
        'from' => 'require|checkName',
        'sign' => 'require',
        'pwd' => 'require',
        'captcha|验证码'=>'require|captcha'
    ];
    protected function checkName($value, $rule='', $data='', $field='')
    {
        $model = new Account();
        $result = $model->getSignInfo($value, $data);
        $arr = $result->toArray();
        if($arr == false){
            return '推广方不存在';
        }
        if($arr['sign'] == false){
            return '标识码不存在';
        }
        if($arr['sign'][0]['status'] == 0){
            return '标识码已被禁用';
        }
        if($arr['sign'][0]['pwd'] !== $data['pwd']){
            return '密码错误';
        }
        return true;
    }

}